// 先判断是否为对象，如果是就递归判断，否则直接返回
function deepCopy(obj) {
    let newObj = obj instanceof Array ? [] : {}
    if (obj && typeof obj === 'object') {
        for (var key in obj) {
            if (obj[key] && typeof obj[key] === 'object') {
                //    如果是对象，递归处理
                newObj[key] = deepCopy(obj[key])
            } else {
                newObj[key] = obj[key]
            }
        }
    } else {
        newObj = obj
    }
    return newObj;
}
function deepClone(obj) {
    var res = {};
    var nodeQueue = [obj];
    var copyQueue = [res];

    while (nodeQueue.length > 0) {
        // 深度优先
        var node = nodeQueue.pop();
        var copy = copyQueue.pop();

        // 广度优先
        // var node = nodeQueue.shift();
        // var copy = copyQueue.shift();

        for (var key in node) {
            var val = node[key]
            if (typeof val !== 'object') {
                copy[key] = val;
            } else {
                nodeQueue.push(val);
                copy[key] = {};
                copyQueue.push(copy[key]);
            }
        }
    }
    return res;
}